package cc.avatar.model.dto;

import java.util.HashSet;
import java.util.Set;

import cc.avatar.model.BusinessException;
import cc.avatar.model.Customer;

public class SaleDto {
	private Customer customer;
	private Long salerId;
    private Long[] productIds;
    private Integer[] amounts;
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public Long[] getProductIds() {
		return productIds;
	}
	public void setProductIds(Long[] productIds) {
		this.productIds = productIds;
	}
	public Integer[] getAmounts() {
		return amounts;
	}
	public void setAmounts(Integer[] amounts) {
		this.amounts = amounts;
	}
	public Long getSalerId() {
		return salerId;
	}
	public void setSalerId(Long salerId) {
		this.salerId = salerId;
	}
	public void validate() {
		Set<Long> ids = new HashSet<Long>();
		for (Long id: productIds)
			ids.add(id);
		if (ids.size() != productIds.length)
		    throw new BusinessException("S03");
	}
    
}
